
#include "common/asyc/taskqueue.h"

void TaskQueue::enqueue(runnable_t* task)
{
	QMutexLocker locker(&m_mutex);
	m_queue.push(task);
}
runnable_t* TaskQueue::dequeue()
{
	QMutexLocker locker(&m_mutex);
	if (m_queue.empty()) return nullptr;
	//.
	runnable_t* objptr = m_queue.top();
	m_queue.pop();
	return objptr;
}
bool TaskQueue::isEmpty() const
{
	QMutexLocker locker(&m_mutex);
	return m_queue.empty();
}
int TaskQueue::queueSize() const
{
	QMutexLocker locker(&m_mutex);
	return m_queue.size();
}